<table width="100%"><tr><td width="20%">
<a href="../index.html">&lt; index</a><br />
<a href="index.html">&lt; 11. Compression toolkit</a><br />
<a href="zip_put.html">&lt; 11.2 Putting data in the buffer</a>
</td><td width="60%">
<p align="center">
=====================================<br />
11.3 Saving the compressed data to a file<br />
=====================================<br />
</p></td><td width="20%">
<a href="zip_load.html">&gt; 11.4 Loading compressed data from a file</a>
</td></tr></table>
<style type="text/css">
.code { color:#444444; background-color:#EEEEEE;}
pre { color:#444444; background-color:#EEEEEE;}
table.param td { border : 1px solid #000000; }
th { background-color: #44BBFF; color: #FFFFFF }
table.none td { border : 0 }
</style>
Once you have finished adding data in the buffer, you can compress it and save it in a file.<br />
<p class="code"><pre>
C++ : int TCODZip::saveToFile(const char *filename)
C   : int TCOD_zip_save_to_file(TCOD_zip_t zip, const char *filename)
</pre></p>
<br />
<table class="param">
<tr><th>Parameter</th><th>Description</th></tr>
<tr><td>zip</td><td>In the C version, the buffer handler, returned by the <a href="zip_init.html">constructor</a>.<br /></td></tr>
<tr><td>filename</td><td>Name of the file</td></tr>
</table>
The function returns the number of (uncompressed) bytes saved.
<br />
Example :<br />
<p class="code"><pre>
C++ : TCODZip zip;
      zip.putChar('A');
      zip.putInt(1764);
      zip.putFloat(3.14f);
      zip.putString("A string");
      zip.putData(nbBytes, dataPtr);
      zip.saveToFile("myCompressedFile.gz");
C   : TCOD_zip_t zip=TCOD_zip_new();
      TCOD_zip_put_char(zip,'A');
      TCOD_zip_put_int(zip,1764);
      TCOD_zip_put_float(zip,3.14f);
      TCOD_zip_put_string(zip,"A string");
      TCOD_zip_put_data(zip,nbBytes, dataPtr);
      TCOD_zip_save_to_file(zip,"myCompressedFile.gz");
</pre></p>
